# Makefile.in, part of dummy configure/Makefile thingy
# for devide to be included as VL-e POC contrib package
# 2007, Charl P. Botha <http://cpbotha.net/>

# prefix is e.g. /some/dir/devide-1.2.3
PREFIX=
# DESTDIR is a fakeroot, i.e. PREFIX is relative to DESTDIR
# DESTDIR=will be set by VL-e build system
# WORKINGDIR is the johannes working directory
WORKINGDIR=

SHELL=sh

default: build

# we have to add this target, as we have a dir called 'build'
# without .PHONY, make will think that 'build' is always up to date
.PHONY: build

build:
	# build local python
	sh johannes/bootstrap_stage2.sh $(WORKINGDIR)
	# make script to start johannes with local python
	echo "#!/bin/sh" > tempj.sh
	echo ". ./python_setup_env.sh" >> tempj.sh
	echo "python johannes/johannes.py -w $(WORKINGDIR)" >> tempj.sh
	chmod +x tempj.sh
	# run script
	./tempj.sh

check: build
	cd $(WORKINGDIR)/inst/devide && ./devide --test

# 1. first do non-destructive mkdir -p, incase this is the first install
#    and there's nothing there yet.
# 2. we need to remove the destination directory and then copy
#    if the dest dir already exists, this will make a new
#    SUBDIR of the destination dir...
install: build
	mkdir -p $(DESTDIR)/$(PREFIX)
	rm -rf $(DESTDIR)/$(PREFIX)
	cp -r $(WORKINGDIR)/inst/devide $(DESTDIR)/$(PREFIX)
